#  - kind: Article
#    properties:
#    - name: __searchable_text_index
#    - name: publishDate
#      direction: desc 
from google.appengine.ext import db
from google.appengine.ext import search

class Article(search.SearchableModel):
  title = db.TextProperty()
  publishDate = db.DateTimeProperty(auto_now_add=True)
  text = db.TextProperty()

# should NOT be returned
article = Article(text ='''This is the totally secret article text 
which talks about sausages and cheese in the middle of itself.''')
article.title = "Fine cuisine"
article.save() 

# should BE returned
article = Article()
article.title = "What I feed my dogs"
article.text = '''This is the totally secret article text 
which talks about sausages and cheese in the middle of itself.'''
article.save() 

print "Results"

query = Article.all().search("sausages cheese dogs").order("-publishDate") 
for a in query: 
  print "%s | %s" % (a.title, a.publishDate)
  
print "Done printing"
